<link rel="stylesheet" href="/assets/home/css/center.css" />

<!-- 头部 -->
<div class="user">
    <div class="avatar wow fadeInUp">
        {if condition="$AutoLogin['avatar'] && is_file('.'.$AutoLogin['avatar'])"}
        <a href="{:url('home/business/profile')}">
            <img src="{$AutoLogin.avatar}" />
        </a>
        {else /}
        <a href="{:url('home/business/profile')}">
            <img src="/assets/home/images/avatar.jpg" />
        </a>
        {/if}
    </div>

    <div class="nickname">{$AutoLogin.nickname}</div>
</div>

<!-- 菜单 -->
<div class="menulist">
    <div class="commonly-used">
        <div class="title">常用工具</div>
        <div class="list">
            <div class="item">
                <a href="{:url('home/business/profile')}">
                    <img src="/assets/home/images/profile.png" alt="">
                    <div class="name">基本资料</div>
                </a>
            </div>

            <div class="item">
                <a href="{:url('home/business/subject')}">
                    <img src="/assets/home/images/course.png" alt="">
                    <div class="name">我的课程</div>
                </a>
            </div>

            {if condition="$AutoLogin.auth == '0'"}
            <div class="item">
                <a href="{:url('home/business/email')}">
                    <img src="/assets/home/images/email.png" alt="">
                    <div class="name">邮箱认证</div>
                </a>
            </div>
            {/if}

            <div class="item">
                <a href="{:url('home/business/coupon_list')}">
                    <img src="/assets/home/images/coupon.png" alt="">
                    <div class="name">我的优惠券</div>
                </a>
            </div>

            <div class="item">
                <a href="collection.html">
                    <img src="/assets/home/images/collection.png" alt="">
                    <div class="name">我的收藏</div>
                </a>
            </div>

            <div class="item">
                <a href="order.html">
                    <img src="/assets/home/images/order_1.png" alt="">
                    <div class="name">我的关注</div>
                </a>
            </div>

            <div class="item">
                <a href="record.html">
                    <img src="/assets/home/images/record.png" alt="">
                    <div class="name">消费记录</div>
                </a>
            </div>

            <div class="item">
                <a href="recharge.html">
                    <img src="/assets/home/images/recharge.png" alt="">
                    <div class="name">余额充值</div>
                </a>
            </div>

            <div class="item">
                <a href="{:url('home/business/contact')}">
                    <img src="/assets/home/images/contact.png" alt="">
                    <div class="name">联系我们</div>
                </a>
            </div>

            <div class="item" id="logout">
                <a>
                    <img src="/assets/home/images/logout_1.png" alt="">
                    <div class="name">退出账号</div>
                </a>
            </div>
        </div>
    </div>

    <div class="promotion">
        <div class="title">推广管理</div>
        <div class="list">
            <div class="item">
                <a href="{:url('home/team/poster')}">
                    <img src="/assets/home/images/poster.png" alt="">
                    <div class="name">推广海报</div>
                </a>
            </div>

            <div class="item">
                <a href="{:url('home/team/index')}">
                    <img src="/assets/home/images/team.png" alt="">
                    <div class="name">我的团队</div>
                </a>
            </div>

            <div class="item">
                <a href="money.html">
                    <img src="/assets/home/images/money.png" alt="">
                    <div class="name">提现</div>
                </a>
            </div>
        </div>
    </div>
</div>

<!-- 底部 -->
{include file="common/footer" /}

<script>
    //退出的绑定事件
    $('#logout').click(() => {
        //mui确认对话框
        mui.confirm(
            '是否确认退出',
            '退出提醒',
            ['确认', '取消'],
            function (res) {
                if (res.index === 0) {
                    //发送ajax请求
                    $.ajax({
                        url: `{:url('home/index/logout')}`,
                        type: 'post',
                        dataType: 'json',
                        success: (success) => {
                            if (success.code) {
                                mui.toast('退出成功')

                                // 关闭当前窗口
                                $('.mui-popup-backdrop').remove()
                                $('.mui-popup').remove()

                                setTimeout(() => {
                                    location.href = `{:url('home/index/login')}`
                                }, 500)

                                return false
                            } else {
                                mui.toast(success.msg)

                                // 关闭当前窗口
                                $('.mui-popup-backdrop').remove()
                                $('.mui-popup').remove()
                            }
                        },
                        error: err => console.log(err)
                    })
                }
            }
        )
    })
</script>
